import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class db_conn
{
   public Connection conn;
	
	public Connection connect(String dbname, String userid, String passwd)
	{
		
		try
		{
		   Class.forName("com.mysql.jdbc.Driver").newInstance();
		   conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/"+dbname,userid,passwd);
		   System.out.println("Connected");
		   return conn;
		
			//Connection conn = db.dbConnect("jdbc:mysql://localhost:3306/test","root","");
		}catch(Exception e)
		{
			e.printStackTrace();
			return null;
		}	
		
	}
	
	//Close DBMS connection
	public void close(Connection conn)
	{
		try{
			if(conn!=null)
				{
				conn.close();
				}
			
		}catch(SQLException e)
		{
			e.printStackTrace();
		}
	}//close
}
